#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdio.h>

int main()
{
    int x, i;
    printf("Input a initial value for i:");
    scanf("%d", &i);
    while ((x = fork()) == -1)
        ;
    if (x == 0)
    {
        printf("When child runs,i=%d \n", i);
        printf("Input a value in child:");
        scanf("%d", &i);
        printf("child i=%d\n", i);
    }
    else
    {
        int status = 0;
        wait(&status);
        printf("Wait success, parent i=%d \n", i);
    }
}